class MaxQueue:

    def __init__(self):
        self.arr = []
        self.help = []
        return

    def max_value(self) -> int:
        return -1 if(len(self.help) == 0) else self.help[0]

    def push_back(self, value: int) -> None:
        self.arr.append(value)
        while(self.help and self.help[-1] < value):
            self.help.pop()
        self.help.append(value)

    def pop_front(self) -> int:
        if(len(self.arr) > 0 and len(self.help) > 0 and self.arr[0] == self.help[0]):
            self.help.pop(0)
        return -1 if(len(self.arr) == 0) else self.arr.pop(0)


class MaxQueue1:
    def __init__(self):
        self.arr = []
        return

    def max_value(self) -> int:
        return -1 if(len(self.arr) == 0) else max(self.arr)

    def push_back(self, value: int) -> None:
        self.arr.append(value)

    def pop_front(self) -> int:
        return -1 if(len(self.arr) == 0) else self.arr.pop(0)


def opt(opts, param2):
    queue = MaxQueue()
    queue1 = MaxQueue1()
    res = []
    res1 = []
    for i in range(0, len(opts)):
        if(opts[i] == 'push_back'):
            queue.push_back(param2[i][0])
            queue1.push_back(param2[i][0])
            res.append(None)
            res1.append(None)
        elif(opts[i] == 'pop_front'):

            res.append(queue.pop_front())
            res1.append(queue1.pop_front())
        elif(opts[i] == 'max_value'):

            res.append(queue.max_value())
            res1.append(queue1.max_value())
        else:
            res1.append(None)
            res.append(None)
        if(res[i] != res1[i]):
            print(i)
    return res


if __name__ == "__main__":
    print(opt(["MaxQueue", "max_value", "pop_front", "max_value", "push_back", "max_value", "pop_front", "max_value", "pop_front", "push_back", "pop_front", "pop_front", "pop_front", "push_back", "pop_front", "max_value", "pop_front", "max_value", "push_back", "push_back", "max_value", "push_back", "max_value", "max_value", "max_value", "push_back", "pop_front", "max_value", "push_back", "max_value", "max_value", "max_value", "pop_front", "push_back", "push_back", "push_back", "push_back", "pop_front", "pop_front", "max_value", "pop_front", "pop_front", "max_value", "push_back", "push_back", "pop_front", "push_back", "push_back", "push_back", "push_back", "pop_front", "max_value", "push_back", "max_value", "max_value", "pop_front", "max_value", "max_value", "max_value", "push_back", "pop_front", "push_back", "pop_front", "max_value", "max_value", "max_value", "push_back", "pop_front", "push_back", "push_back", "push_back", "pop_front", "max_value", "pop_front", "max_value", "max_value", "max_value", "pop_front", "push_back", "pop_front", "push_back", "push_back", "pop_front", "push_back", "pop_front", "push_back", "pop_front", "pop_front", "push_back", "pop_front", "pop_front", "pop_front", "push_back", "push_back", "max_value", "push_back", "pop_front", "push_back", "push_back", "pop_front"],
              [[], [], [], [], [46], [], [], [], [], [868], [], [], [], [525], [], [], [], [], [123], [646], [], [229], [], [], [], [871], [], [], [285], [], [], [], [], [45], [140], [837], [545], [], [], [], [], [], [], [561], [237], [], [633], [98], [806], [717], [], [], [186], [], [], [], [], [], [], [268], [], [29], [], [], [], [], [866], [], [239], [3], [850], [], [], [], [], [], [], [], [310], [], [674], [770], [], [525], [], [425], [], [], [720], [], [], [], [373], [411], [], [831], [], [765], [701], []]))


# Your MaxQueue object will be instantiated and called as such:
# obj = MaxQueue()
# param_1 = obj.max_value()
# obj.push_back(value)
# param_3 = obj.pop_front()
